package com.ts.main.admin.service;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ts.common.dto.FileDto;
import com.ts.main.admin.entity.FileEntity;
import com.ts.main.admin.mapper.FileMapper;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author lk
* @description 针对表【t_file(文件表)】的数据库操作Service实现
* @createDate 2025-06-09 00:56:13
*/
@AllArgsConstructor
@Service
public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntity> {

    public FileDto addGoodsFile(FileDto dto) {
        FileEntity entity = new FileEntity();
        BeanUtils.copyProperties(dto, entity);
        save(entity);
        return dto;
    }

    public List<FileDto> addGoodsListFile(List<FileDto> dtos) {
        List<FileEntity> list = BeanUtil.copyToList(dtos, FileEntity.class);
        saveBatch(list);
        return dtos;
    }
}




